<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">

<ui:composition template="/WEB-INF/template/basicTemplate.xhtml">
	<ui:define name="content">
		<h:form id="form">
			<h:inputHidden rendered="#{param.link!=null}"
				value="#{linkController.candidateHistoryLink()}"></h:inputHidden>
			<h:inputHidden rendered="#{param.link!=null}"
				value="#{candidateHistoryController.createLists()}"></h:inputHidden>
			<h:inputHidden rendered="#{param.link!=null}"
				value="#{menuController.setUserRank(2)}"></h:inputHidden>
			<h:inputHidden rendered="#{menuController.userRank != 2}"
				value="#{menuController.redirect()}"></h:inputHidden>
			<h:form rendered="#{menuController.userRank == 2}">
			<h:outputText styleClass="boldText"
				value="Welcome, #{candidateHistoryController.candidateDTO.firstName} #{candidateHistoryController.candidateDTO.lastName}!"></h:outputText>
				<br></br>
				<br></br>
			<h:outputText styleClass="tableTitle"
				rendered="#{candidateHistoryController.hasPendingInterviews}"
				value="Interview invitations" />
			<h:dataTable
				styleClass="templatetable"
				rendered="#{candidateHistoryController.hasPendingInterviews}"
				value="#{candidateHistoryController.pendingInterviews}" var="int"
				binding="#{candidateHistoryController.dataTable}">
				<h:column>
					<f:facet name="header">
						<h:outputText value="Test name" />
					</f:facet>
					<div class="first"><h:outputText value="#{int.template.title}" /></div>
				</h:column>
				<h:column>
					<f:facet name="header">
						<h:outputText value="Date" />
					</f:facet>
					<h:outputText value="#{int.dateString}" />
				</h:column>
				<h:column>
					<f:facet name="header">
						<h:outputText value="Start time" />
					</f:facet>
					<h:outputText value="#{int.startTime}" />
				</h:column>
				<h:column>
					<f:facet name="header">
						<h:outputText value="Duration" />
					</f:facet>
					<h:outputText value="#{int.template.duration}'" />
				</h:column>
				<h:column>
					<f:facet name="header">
						<h:outputText value="Location" />
					</f:facet>
					<h:outputText value="#{int.room.address}" />
				</h:column>
				
				<h:column>
					<f:facet name="header">
						<h:outputText value="Answer" />
					</f:facet>
					<div align="center">
					<h:commandButton styleClass="button"
						actionListener="#{candidateHistoryController.acceptTest}"
						value="Accept">

					</h:commandButton>
					<h:commandButton styleClass="button"
						actionListener="#{candidateHistoryController.declineTest}"
						value="Decline">

					</h:commandButton>
					</div>
				</h:column>
			</h:dataTable>
			<br></br>
			<h:outputText styleClass="tableTitle"
				rendered="#{candidateHistoryController.hasAcceptedInterviews}"
				value="Assigned tests" />
			<h:dataTable
				rendered="#{candidateHistoryController.hasAcceptedInterviews}"
				value="#{candidateHistoryController.acceptedInterviews}" var="int"
				binding="#{candidateHistoryController.dataTableAccepted}"
				styleClass="templatetable">
				<h:column>
					<f:facet name="header">
						<h:outputText value="Test name" />
					</f:facet>
					<div class="first"><h:outputText value="#{int.template.title}" /></div>
				</h:column>
				<h:column>
					<f:facet name="header">
						<h:outputText value="Date" />
					</f:facet>
					<h:outputText value="#{int.dateString}" />
				</h:column>
				<h:column>
					<f:facet name="header">
						<h:outputText value="Start time" />
					</f:facet>
					<h:outputText value="#{int.startTime}" />
				</h:column>
				<h:column>
					<f:facet name="header">
						<h:outputText value="Duration" />
					</f:facet>
					<h:outputText value="#{int.template.duration}'" />
				</h:column>
				<h:column>
					<f:facet name="header">
						<h:outputText value="Location" />
					</f:facet>
					<h:outputText value="#{int.room.address}" />
				</h:column>
				
				<h:column>
					<f:facet name="header">
						<h:outputText value="Options" />
					</f:facet>
					<div align="center">
					<h:commandButton styleClass="#{int.generateButtonStyleClass}"
						disabled="#{int.generated }"
						actionListener="#{candidateHistoryController.generateTest}"
						value="Generate test">

					</h:commandButton>
					<a href="#top"></a>
					<h:commandButton styleClass="#{int.startButtonStyleClass}"
						disabled="#{int.startTest}"
						actionListener="#{candidateHistoryController.startTest}"
						value="Start test">
					</h:commandButton>
					</div>
				</h:column>

			</h:dataTable>
			<h:messages styleClass="#{candidateHistoryController.messageClass}" id="mess"></h:messages>
			<br></br>
						<h:outputText styleClass="tableTitle"
				rendered="#{candidateHistoryController.hasHistory}" value="History" />
			<h:panelGrid columns="2">
				<h:column>
					<h:dataTable value="#{candidateHistoryController.allInterviews}"
						var="int" binding="#{candidateHistoryController.dataTableHistory}">
						<h:column>
							<f:facet name="header">
								<h:outputText value="Test name" />
							</f:facet>
							<div class="first"><h:outputText value="#{int.template.title}" /></div>
						</h:column>
						<h:column>
							<f:facet name="header">
								<h:outputText value="Date" />
							</f:facet>
							<h:outputText value="#{int.dateString}" />
						</h:column>
						
						<h:column>
							<f:facet name="header">
								<h:outputText value="Results" />
							</f:facet>
							<h:graphicImage library="images" name="#{int.taken}"
												height="20" width="20"></h:graphicImage>
						</h:column>
						<h:column>
							<f:facet name="header">
								<h:outputText value="Options" />
							</f:facet>
							<h:commandButton
								actionListener="#{candidateHistoryController.view}"
								styleClass="button" value="View">
							</h:commandButton>

						</h:column>
					</h:dataTable>
				</h:column>
			</h:panelGrid>
			</h:form>
		</h:form>
	</ui:define>

</ui:composition>
</html>